package com.heyqing.medium.day5;

/**
 * ClassName:MaxGoodNumber
 * Package:com.heyqing.medium.day5
 * Description:
 *
 * @Date:2024/10/6
 * @Author:Heyqing
 */
public class MaxGoodNumber {
    public int maxGoodNumber(int[] nums) {
        //因题中明确nums长度为3，故用枚举即可
        int max = 0;
        String b1 = Integer.toBinaryString(nums[0]);
        String b2 = Integer.toBinaryString(nums[1]);
        String b3 = Integer.toBinaryString(nums[2]);
        StringBuilder sb1 = new StringBuilder(b1);
        sb1.append(b2);
        sb1.append(b3);
        StringBuilder sb2 = new StringBuilder(b1);
        sb2.append(b3);
        sb2.append(b2);
        StringBuilder sb3 = new StringBuilder(b2);
        sb3.append(b1);
        sb3.append(b3);
        StringBuilder sb4 = new StringBuilder(b2);
        sb4.append(b3);
        sb4.append(b1);
        StringBuilder sb5 = new StringBuilder(b3);
        sb5.append(b2);
        sb5.append(b1);
        StringBuilder sb6 = new StringBuilder(b3);
        sb6.append(b1);
        sb6.append(b2);
        max = Math.max(Integer.parseInt(sb1.toString(),2),Integer.parseInt(sb2.toString(),2));
        max = Math.max(max,Integer.parseInt(sb3.toString(),2));
        max = Math.max(max,Integer.parseInt(sb4.toString(),2));
        max = Math.max(max,Integer.parseInt(sb5.toString(),2));
        max = Math.max(max,Integer.parseInt(sb6.toString(),2));
        return max;
    }
}
